import io.reactivex.Maybe;

public class C16 {

    public static void main(String[] args) {
        /* One example is the firstElement() operator, which is similar to first(), 
         * but it returns an empty result if no elements are emitted.
         */
        // has emission
        Maybe<Integer> presentSource = Maybe.just(100);
        presentSource.subscribe(s -> System.out.println("Process 1 received:" + s),
                                Throwable::printStackTrace,
                                () -> System.out.println("Process 1 done!"));
        //no emission
        Maybe<Integer> emptySource = Maybe.empty();
        emptySource.subscribe(s -> System.out.println("Process 2 received:" + s),
                              Throwable::printStackTrace,
                              () -> System.out.println("Process 2 done!"));

    }

}
//EOP
